package com.system.goodstypeserver.controller;

import com.alibaba.fastjson.JSONObject;
import com.netflix.hystrix.contrib.javanica.annotation.DefaultProperties;
import com.system.goodstypeserver.bus.TestSender;
import com.system.commonutils.bean.ApiResult;
import com.system.commonutils.utils.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "测试",tags = "商品种类-商品种类测试API")
@RestController
@DefaultProperties(defaultFallback = "golbalFallback")
public class TestController {


    @Autowired()
    RedisUtil redisUtil;

    @Autowired
    TestSender testSender;

    @ApiOperation(value = "商品种类模块测试")
    @GetMapping(value = "hello",produces = "application/json;charset=UTF-8")
    public ApiResult hello(){

        return ApiResult.success("商品种类模块测试");
    }



    /**
     * 默认熔断回调
     * @return
     */
    public String golbalFallback(Throwable throwable){
        String localizedMessage = throwable.getLocalizedMessage();
        return JSONObject.toJSONString(ApiResult.failure(localizedMessage));
    }
}
